package me.xue.communityhealth.repo;

import com.github.pagehelper.Page;
import me.xue.communityhealth.model.Information;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface InformationRepository {

    @Insert("INSERT INTO `information`(title,content,type) VALUES(#{title},#{content},#{type})")
    int save(Information information);

    @Update("UPDATE `information` SET `title`=#{title},`content`=#{content},`type`=#{type} WHERE `id`=#{id}")
    int update(Information information);

    @Delete("DELETE FROM `information` WHERE `id`=#{id}")
    int delete(Integer id);

    @Select("SELECT * FROM `information` WHERE `id`=#{id}")
    Information findOne(Integer id);

    @Select("SELECT * FROM `information`")
    List<Information> findAll();

    @Select("SELECT * FROM `information`")
    Page<Information> pagedAll();
}
